package com.cxdr.awsips.distribute.bean;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;

import com.cxdr.awsips.common.logger.LogFactory;
/**
 * 	1):CREATE_TIME:格式应该为yyyy-mm-dd hh24:mi:ss,系统当前时间
	2):SOURCE_TYPE:值未填写
	3):SOURCE_PATH:值有问题,应该是监控源的地址，不是应用的地址
	4):BEGIN_TIME:文件传送开始时间，yyyy-mm-dd hh24:mi:ss
	5):END_TIME:文件传送结束时间,yyyy-mm-dd hh24:mi:ss
	6):CREATE_DAY:入库日，系统当前的日
	7):CREATE_HOUR:入库时，hh24
 * @author pugang
 *
 */
public class DistributionLog {
	private static Logger logger = LogFactory.makeNewLogger(DistributionLog.class);
	private String ID;
	private String file_name; // 源文件名
	private String partition_month; // 分区月
	private String source_type;// 提取方式
	private String source_address;// 源文件地址
	private String source_path;// 源文件路径
	private String target_type;// 目的推送方式
	private String tartget_address;// 目的地址
	private String target_path;// 推送路径
	private Date create_time;// 创建时间
	private Date begin_time;// 推送时间
	private Date end_time; // 结束时间
	private String result;// 推送结果
	private String create_day;
	private String create_hour;
	private String target_id; 
	private String station_id;
	private String file_date;
	private String file_type;
	public DistributionLog() {
	}

	public DistributionLog(String fileName) {
		this.file_name = fileName;
		parseAttr();
	}

	private void parseAttr() {
		_parseFileNameAttr(file_name);
		// 分区月 不设置，在外部新建LOG对象的时候设置，这样可以避免新建多余的对象
//		source_type = SystemConfig.get("source.type");
//		source_address = SystemConfig.get("source.address");
//		File file = new File(source_path+File.separator+file_name);
//		create_time = new Date(file.lastModified());
	}
	private void _parseFileNameAttr(String fileName){
//		SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
		String[] infos = fileName.split("_");
		for(int i =0;i<infos.length;i++){
			String info = infos[i];
			if(info.length()==14){
				file_date = info;
			}
			//站号
			if("I".equalsIgnoreCase(info)){
				info=infos[++i];
				info = info.replaceAll("-REG", "");
				station_id = info;
				continue;
			}
			//文件类型
		}
		if(fileName.contains("O_AWS_FTM")){
			file_type=FileType.E.name();//"地面气象要素数据文件";
		}
		if(fileName.contains("O_AWS-PRF_FTM")){
			file_type=FileType.N.name();//"地面自动站雨量观测资料";
		}
		if(fileName.contains("O_AWS_DAY")){
			file_type=FileType.D.name();//"自动站日数据文件";
		}
		if(fileName.contains("R_AWS_FTM")){
			file_type=FileType.Z.name();//"自动站状态信息文件";
		}
		if(fileName.contains("O_ARS_FTM")){
			file_type=FileType.R.name();//"自动站气象辐射资料";
		}
	}
	public String getID() {
		return ID;
	}

	public void setID(String iD) {
		ID = iD;
	}

	public String getFile_name() {
		return file_name;
	}

	public void setFile_name(String file_name) {
		this.file_name = file_name;
	}

	public String getPartition_month() {
		return partition_month;
	}

	public void setPartition_month(String partition_month) {
		this.partition_month = partition_month;
	}

	public String getSource_type() {
		return source_type;
	}

	public void setSource_type(String source_type) {
		this.source_type = source_type;
	}

	public String getSource_address() {
		return source_address;
	}

	public void setSource_address(String source_address) {
		this.source_address = source_address;
	}

	public String getSource_path() {
		return source_path;
	}

	public void setSource_path(String source_path) {
		this.source_path = source_path;
	}

	public String getTarget_type() {
		return target_type;
	}

	public void setTarget_type(String target_type) {
		this.target_type = target_type;
	}

	public String getTartget_address() {
		return tartget_address;
	}

	public void setTartget_address(String tartget_address) {
		this.tartget_address = tartget_address;
	}

	public String getTarget_path() {
		return target_path;
	}

	public void setTarget_path(String target_path) {
		this.target_path = target_path;
	}

	public Date getBegin_time() {
		return begin_time;
	}

	public void setBegin_time(Date begin_time) {
		this.begin_time = begin_time;
	}

	public Date getEnd_time() {
		return end_time;
	}

	public void setEnd_time(Date end_time) {
		this.end_time = end_time;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public Date getCreate_time() {
		return create_time;
	}

	public void setCreate_time(Date create_time) {
		this.create_time = create_time;
	}

	public String getCreate_day() {
		return create_day;
	}

	public void setCreate_day(String create_day) {
		this.create_day = create_day;
	}

	public String getCreate_hour() {
		return create_hour;
	}

	public void setCreate_hour(String create_hour) {
		this.create_hour = create_hour;
	}

	public String getTarget_id() {
		return target_id;
	}

	public void setTarget_id(String target_id) {
		this.target_id = target_id;
	}

	public String getStation_id() {
		return station_id;
	}

	public void setStation_id(String station_id) {
		this.station_id = station_id;
	}

	public String getFile_date() {
		return file_date;
	}

	public void setFile_date(String file_date) {
		this.file_date = file_date;
	}

	public String getFile_type() {
		return file_type;
	}

	public void setFile_type(String file_type) {
		this.file_type = file_type;
	}
}
